package com.kk.xhr.model.dao.custom;

import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;

/**
 * 通用批量插入
 *
 * @author luokexiong
 * @version 1.0 2021/2/17 11:38 上午
 * @since 1.0.0
 */
@Mapper
public interface CommonCustomMapper {

    /**
     * 多个插入
     *
     * @param insertStatement 插入语句
     * @return 插入的行数
     */
    @InsertProvider(type = SqlProviderAdapter.class, method = "insertMultiple")
    <T> int insertMultiple(MultiRowInsertStatementProvider<T> insertStatement);

    @Update("truncate table ${table}")
    void truncate(@Param("table") String table);
}
